<template>
  <div class="container lawyer-details pb">
    <p class="bread">
      <a href="#/">首页</a> >
      <a href="#/lawyerlist" class="font-s-18">法律服务</a> >
      <a href="#/lawyerdetails" class="font-s-16">律师详情</a> >
      <a href="javascript:void(0);" class="font-s-14">客户评价</a>
    </p>
    <div class="box-border bg-c-fff content">
      <h3>请您就本次服务队律师进行评价，您的评价对我们非常重要，感谢您的配合。</h3>
      <form @submit.prevent="onSubmitClick">
        <div class="box">
          <evaluate ref="num"></evaluate>
          <textarea v-model="evaluateOne"></textarea>
          <div class="fix btn">
            <div class="flo-right">
              <input type="submit" value="提交评价" class="blue-button small-btn-css">
              <input type="button" value="取消" @click="cancel" class="blue-button small-btn-css">
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>
<script type="text/javascript">
import Evaluate from '../components/Evaluate'
export default {
  components: {
    Evaluate
  },
  data() {
    return {
      evaluateOne: ''
    }
  },
  methods: {
    onSubmitClick() {
      if (!this.evaluateOne && this.$refs.num.index === 1) {
        this.$toasted.show('请写下您对律师的评价')
        return
      }
      this.$http.post('/evaluate/submit', {
        evaluateId: this.$route.query.id,
        satisfactory: this.$refs.num.index,
        evaluateType: 1,
        evaluateOne: this.evaluateOne
      }).then(data => {
        if (data.data.httpCode === 200) {
          this.$toasted.show('提交成功，感谢您留下宝贵意见')
          this.$router.push('/lawyerlist')
        } else {
          console.log(data.data.msg)
          this.$toasted.show(data.data.msg)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    cancel() {
      this.$refs.num.index = 3
      this.evaluateOne = ''
    }
  }
}

</script>
<style type="text/css" scoped>
.box-border {
  border: 1px solid #ddd;
}

.pb {
  padding-bottom: 132px;
}

.content h3 {
  border-bottom: 1px solid #dddddd;
  color: #282828;
  line-height: 40px;
  padding-left: 40px;
  font-size: 14px;
}

.content .box {
  padding: 0 40px;
}

textarea {
  width: 100%;
  height: 120px;
  margin-top: 15px;
}

.content .box .btn input {
  margin: 20px 5px 30px 40px;
}

</style>
